import { request } from '../../request/index.js'
import regeneratorRuntime from '../../lib/runtime/runtime';
Page({
  data:{
    goods:[],
    ishidden:true,
    inputValue:""
  },
  TimeId:-1,
  handeSearch(e){
    const {value} = e.detail;
    if(value.trim().length==0){
      this.setData({
        goods:[],
        ishidden:true
      })
      return;
    }
    clearTimeout(this.TimeId);
    this.TimeId = setTimeout(() => {
      this.Query(value);
    }, 1000);
  },
  async Query(query){
    const res =await  request({url:'/goods/search',data:{query}});
    this.setData({
      goods:res.goods,
      ishidden:false
    })
  },
  cancle(){
    this.setData({
      goods:[],
      ishidden:true,
      inputValue:""
    })
  }
})